import { Injectable } from '@angular/core';
import { BaseService } from './base.service';
@Injectable({
  providedIn: 'root'
})
export class RoleService extends BaseService {
  //添加角色
  createRole(RoleInfo) {
    const url = 'api/role';
    return this.post(url, RoleInfo);
  }
  //编辑角色
  updateRole(RoleInfo) {
    const url = 'api/role';
    return this.put(url, RoleInfo);
  }
  //角色详情
  getRoleInfoById(Id) {
    const url = 'api/role';
    return this.get(`${url}/${Id}`);
  }
  //角色列表
  queryRoles(params?: { name: string; pageIndex: number; countOfPage: number; }) {
    const url = 'api/role';
    return this.get(url, { params });
  }
  //删除角色
  deleteRole(Id) {
    const url = 'api/role';
    return this.delete(`${url}/${Id}`);
  }
  //权限列表
  queryAccountPermitss(params: { authObjectId: string; authObjectType: string; }) {
    const url = 'api/accountpermits';
    return this.get(url, { params });
  }
  //添加角色下得用户
  createAccountRoles(list) {
    const url = 'api/accountroles';
    return this.post(url, list);
  }
  //添加权限
  createAccountPermits(list) {
    const url = 'api/accountpermits';
    return this.post(url, list);
  }


  getUserRoles(params) {
    let url = `api/accountroles`;
    return this.get(url, {
      params
    });
  }

  delAccountRolesById(accountRoleId: string) {
    let url = `api/accountroles/${accountRoleId}`;
    return this.delete(url);
  }
}
